package avicit.bdp.oss.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.bdp.oss.utils.stats.Capacity;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.Id;
import avicit.platform6.core.annotation.log.LogField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2020-11-12
 * @类说明：BucketDto
 * @修改记录：
 * @注意事项：
 * @主要功能：桶Entity
 */
@ApiModel(value = "BucketDto", description = "bdp_oss_bucket")
@Table(name = "bdp_oss_bucket")
public class BucketDto extends BaseDTO {
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @Id
    @LogField
    @ApiModelProperty(value = "主键")
    @FieldRemark(column = "id", field = "id", name = "id")
    @javax.persistence.Id
    @Column(name = "id")
    private String id;

    /**
     * 桶名称
     */
    @LogField
    @ApiModelProperty(value = "桶名称，唯一")
    @FieldRemark(column = "bucket_name", field = "bucket_name", name = "桶名称")
    @Column(name = "bucket_name")
    private String bucketName;

    /**
     * 桶策略
     */
    @LogField
    @ApiModelProperty(value = "桶策略")
    @FieldRemark(column = "bucket_strategy", field = "bucket_strategy", name = "桶策略")
    @Column(name = "bucket_strategy")
    private String bucketStrategy;

    /**
     * 高级授权信息
     */
    @LogField
    @ApiModelProperty(value = "高级授权信息")
    @FieldRemark(column = "auth_info", field = "auth_info", name = "高级授权信息")
    @Column(name = "auth_info")
    private String authInfo;

    /**
     * 容量
     */
    @LogField
    @ApiModelProperty(value = "容量")
    @FieldRemark(column = "capacity", field = "capacity", name = "容量")
    @Column(name = "capacity")
    private long capacity;

    /**
     * 对象总数
     */
    @LogField
    @ApiModelProperty(value = "对象总数")
    @FieldRemark(column = "object_num", field = "object_num", name = "对象总数")
    @Column(name = "object_num")
    private long objectNum;

    /**
     * 指标统计信息
     */
    @LogField
    @ApiModelProperty(value = "指标统计信息")
    @FieldRemark(column = "bucket_metric_stats", field = "bucket_metric_stats", name = "指标统计信息")
    @Column(name = "bucket_metric_stats")
    private String bucketMetricStats;

    /**
     * Rest接口使用，存储容量
     */
    @ApiModelProperty(value = "Rest接口使用，存储容量")
    @Transient
    private Capacity retCapacity;

    /**
     * 无参构造函数，mybatis会用到
     */
    public BucketDto() {

    }

    /**
     * 有参构造函数
     * @param id
     * @param bucketName
     * @param bucketStrategy
     * @param authInfo
     * @param capacity
     * @param objectNum
     */
    public BucketDto(String id, String bucketName, String bucketStrategy, String authInfo,
                     long capacity, long objectNum,  String bucketMetricStats, Capacity retCapacity) {
        this.id = id;
        this.bucketName = bucketName;
        this.bucketStrategy = bucketStrategy;
        this.authInfo = authInfo;
        this.capacity = capacity;
        this.objectNum = objectNum;
        this.bucketMetricStats = bucketMetricStats;
        this.retCapacity = retCapacity;
    }

    public String getId() {
        return id;
    }

    public String getBucketName() {
        return bucketName;
    }

    public String getBucketStrategy() {
        return bucketStrategy;
    }

    public String getAuthInfo() {
        return authInfo;
    }

    public long getCapacity() {
        return capacity;
    }

    public long getObjectNum() {
        return objectNum;
    }

    public String getBucketMetricStats() {
        return bucketMetricStats;
    }

    public Capacity getRetCapacity() {
        return retCapacity;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setBucketName(String bucketName) {
        this.bucketName = bucketName;
    }

    public void setBucketStrategy(String bucketStrategy) {
        this.bucketStrategy = bucketStrategy;
    }

    public void setAuthInfo(String authInfo) {
        this.authInfo = authInfo;
    }

    public void setCapacity(long capacity) {
        this.capacity = capacity;
    }

    public void setObjectNum(long objectNum) {
        this.objectNum = objectNum;
    }

    public void setBucketMetricStats(String bucketMetricStats) {
        this.bucketMetricStats = bucketMetricStats;
    }

    public void setRetCapacity(Capacity retCapacity) {
        this.retCapacity = retCapacity;
    }

    @Override
    public String getLogFormName() {
        if (StringUtils.isEmpty(super.logFormName)) {
            return "桶管理";
        } else {
            return super.logFormName;
        }
    }

    @Override
    public String getLogTitle() {
        if (StringUtils.isEmpty(super.logTitle)) {
            return "桶";
        } else {
            return super.logTitle;
        }
    }

    public static BucketDto.Builder builder() {
        return new BucketDto.Builder();
    }

    public static final class Builder {
        String id;
        String bucketName;
        String bucketStrategy;
        String authInfo;
        long capacity;
        long objectNum;
        String bucketMetricStats;
        Capacity retCapacity;

        public Builder() {
        }

        public BucketDto.Builder id(String id) {
            this.id = id;
            return this;
        }

        public BucketDto.Builder bucketName(String bucketName) {
            this.bucketName = bucketName;
            return this;
        }

        public BucketDto.Builder bucketStrategy(String bucketStrategy) {
            this.bucketStrategy = bucketStrategy;
            return this;
        }

        public BucketDto.Builder authInfo(String authInfo) {
            this.authInfo = authInfo;
            return this;
        }

        public BucketDto.Builder capacity(long capacity) {
            this.capacity = capacity;
            return this;
        }

        public BucketDto.Builder objectNum(long objectNum) {
            this.objectNum = objectNum;
            return this;
        }

        public BucketDto.Builder bucketMetricStats(String bucketMetricStats) {
            this.bucketMetricStats = bucketMetricStats;
            return this;
        }

        public BucketDto.Builder retCapacity( Capacity retCapacity) {
            this.retCapacity = retCapacity;
            return this;
        }

        public BucketDto build() {
            return new BucketDto(id, bucketName, bucketStrategy, authInfo, capacity,
                    objectNum, bucketMetricStats, retCapacity);
        }
    }
}
